﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using WIMMP.BLL;

namespace WIMMP
{
    public partial class _Default : System.Web.UI.Page
    {
        Player myPlayer;
        protected void Page_Load(object sender, EventArgs e)
        {

            myPlayer = new Player();
            UpdateControls();
        }

        private void UpdateControls()
        {
            CurrentSongIndexLabel.Text = "#" + myPlayer.CurrentSongIndex.ToString() + ": ";
            CurrentSongLabel.Text = myPlayer.CurrentSong;

            GridView1.DataSource = myPlayer.NowPlaying;
            GridView1.DataBind();
        }


        protected void PrevButton_Click(object sender, EventArgs e)
        {
            myPlayer.Prev();
            UpdateControls();
        }

        protected void PlayPauseButton_Click(object sender, EventArgs e)
        {
            myPlayer.Pause();
        }

        protected void NextButton_Click(object sender, EventArgs e)
        {
            myPlayer.Next();
            UpdateControls();
        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Song song = (Song)e.Row.DataItem;
                if (song.PlayListIndex == myPlayer.CurrentSongIndex)
                {
                    e.Row.CssClass = "CurrentSong";
                }

            }
        }

        protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
        {
        }
    }
}
